package.path = package.path .. ';lib/?.lua;?.lua'

require "ncluasoap"

msgTable = {
	address = "http://150.162.202.1:8080/Soccer/ConsultaDados",
	namespace = "http://webservices/",
}
total_passes = "0"
total_faltas = "0"
total_desarmes = "0"
total_cartoes = "0"
total_cruzamentos = "0"

function getAcaoJogadorResponse(xmlTable)
	print("-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-")
	print("Tamanho: "..#xmlTable)
	for k, v in pairs(xmlTable) do
		print(k,v)
	end
	print("-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-")
	
	if (xmlTable[2] ~= nil) then
		total_passes = tostring(xmlTable[2])
	end
end

function ws_get_total_passes()
	msgTable.operationName = "getAcaoJogador"
	msgTable.params = {
		rodada = 1,
		Time = 1,
		tempo = 1,
		acao = 1
	}
	print(ncluasoap.call(msgTable, getAcaoJogadorResponse))
	return total_passes
end

function getFaltasCountResponse(xmlTable)
	print("-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-")
	print("Tamanho: "..#xmlTable)
	for k, v in pairs(xmlTable) do
		print(k,v)
	end
	print("-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-")
	
	if (xmlTable[2] ~= nil) then
		total_faltas = tostring(xmlTable[2])
	end
end

function ws_get_total_faltas()
	msgTable.operationName = "getFaltasCount"
	msgTable.params = {
		rodada = 1,
		Time = 1,
		tempo = 1,
	}
	print(ncluasoap.call(msgTable, getFaltasCountResponse))
	return total_faltas
end

function getDesarmesCountResponse(xmlTable)
	print("-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-")
	print("Tamanho: "..#xmlTable)
	for k, v in pairs(xmlTable) do
		print(k,v)
	end
	print("-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-")
	
	if (xmlTable[2] ~= nil) then
		total_desarmes = tostring(xmlTable[2])
	end
end

function ws_get_total_desarmes()
	msgTable.operationName = "getDesarmesCount"
	msgTable.params = {
		rodada = 1,
		Time = 1,
		tempo = 1
	}
	print(ncluasoap.call(msgTable, getDesarmesCountResponse))
	return total_desarmes
end

function getCartoesCountResponse(xmlTable)
	print("-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-")
	print("Tamanho: "..#xmlTable)
	for k, v in pairs(xmlTable) do
		print(k,v)
	end
	print("-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-")
	
	if (xmlTable[2] ~= nil) then
		total_cartoes = tostring(xmlTable[2])
	end
end

function ws_get_total_cartoes()
	msgTable.operationName = "getCartoesCount"
	msgTable.params = {
		rodada = 1,
		Time = 1,
		tempo = 1
	}
	print(ncluasoap.call(msgTable, getCartoesCountResponse))
	return total_cartoes
end

-- CADE?
function ws_get_total_gols()
	msgTable.operationName = "getAcaoJogador"
	msgTable.params = {
		rodada = 1,
		Time = 1,
		tempo = 1,
	}
	print(ncluasoap.call(msgTable, getAcaoJogadorResponse))
	return total_passes
end
--

function getCruzamentoCountResponse(xmlTable)
	print("-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-")
	print("Tamanho: "..#xmlTable)
	for k, v in pairs(xmlTable) do
		print(k,v)
	end
	print("-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-")
	
	if (xmlTable[2] ~= nil) then
		total_cruzamentos = tostring(xmlTable[2])
	end
end

function ws_get_total_cruzamentos()
	msgTable.operationName = "getCruzamentoCount"
	msgTable.params = {
		rodada = 1,
		Time = 1,
		tempo = 1
	}
	print(ncluasoap.call(msgTable, getCruzamentoCountResponse))
	return total_cruzamentos
end

-- CADE?
function ws_get_total_chutes()
	msgTable.operationName = "getAcaoJogador"
	msgTable.params = {
		Rodada = 1,
		Time = 1,
		tempo = 1,
		acao = 1
	}
	print(ncluasoap.call(msgTable, getAcaoJogadorResponse))
	return total_passes
end
